// pages/collect/collect.js
import {collect,delcollect} from '../../utils/http'
Page({
    data: {
        shop:[]
    },
    onLoad: function (options) {
        this.getlist()
    },
    getlist(){
        let token= wx.getStorageSync('token')
        collect(token).then(res=>{
            console.log(res)
            this.setData({shop:res.data})
        })
    },
    delgoodid(e){
        console.log(e)
        let id = e.currentTarget.dataset.id
        let index = e.currentTarget.dataset.index
        let token=wx.getStorageSync('token')
        delcollect(id,token).then(res=>{
            let shop=this.data.shop
            if(shop.length<=1){
                this.setData({shop:[]})
            }
            this.getlist()
        })
    },

})